home *** CD-ROM | disk | FTP | other *** search
-
- ~4Dgifts/toolbox/src/exampleCode/opengl/nurbsTrim README
-
- nurbsTrim - A NURBS surface trimmed by a NURBS curve
-
-
-
- "Trimming NURBS surfaces is considered an advanced topic. If this
- is your first exposure to a NURBS, experiment first with curves
- and surfaces, then move on to trimmed surfaces."
-
- Josie Wernecke, _The Inventor Mentor_
-
-
- No foolin', Josie! There are some fine points of trimming NURBS
- that are probably documented somewhere, but I came upon them the
- hard way.
-
- This directory contains examples of trimmed NURBS in OpenGL and
- in Inventor, as well as an easy Makefile and this README.
-
- To make sense of the examples, make sure you know the NURBS basics,
- then read about the obstacles I encountered along the way to making
- trimmed NURBS work.
-
- Good background reading can be found in chapter 11, "Evaluators
- and NURBS", of the OpenGL Programming Guide, especially in the
- section on "The GLU NURBS Interface" (pages 343-353), and in
- chapter 8, "Curves and Surfaces", of the Inventor Mentor, especially
- in the section on "NURBS Surfaces" (pages 199-207). The complete
- bibliographic references are
-
- J. Neider, T. Davis, M. Woo, _OpenGL Programming Guide_,
- (1993, Addison Wesley) ISBN #0-201-63274-8.
-
- J. Wernecke, _The Inventor Mentor_, (1993, Addison Wesley)
- ISBN #0-201-62495-8.
-
- Knot values for NURBS curves and surfaces are not important; the
- only thing that matters is the values of the knots relative to one
- another. Knot vectors must be monotonically non-decreasing, and
- when the same knot value is repeated k times, the curve or surface
- displays an (N-k)th order discontinuity, where N is the order of
- the NURBS. This is widely known and well documented.
-
- But not so widely known is that knot values for trimmed NURBS
- surfaces do indeed matter. The control points of the profile
- curve must all reside in a rectangle in U-V space defined by the
- knot vectors of the NURBS surface. Control points outside of
- this rectangle cause the surface not to be rendered.
-
- In the Inventor example, the knot vectors of the NURBS surface are
-
- uKnotVector [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
- vKnotVector [ 2, 2, 2, 2, 3, 4, 4, 4, 4 ]
-
- There are 10 U knots, and the surface has 6 U control points, so it
- is of order 4 (=10-6) in the U dimension. Likewise, because there
- are 9 V knots and 5 V control points, it is of order 4 (=9-5) in the
- V dimension.
-
- Because the order is 4, notice the 4th and (numKnots-4)th knots.
- These knots define the boundaries of the valid region in U-V space
- where the surface is actually visible. Counting 4 knots in, from
- the ends of the U knot vector, we see knots with values of 3 and 6.
- Likewise, counting 4 knots in from both ends of the V knot vector,
- we see knots with values of 2 and 4.
-
- The values for the control points of the NURBS profile curve must fall
- into the rectangle in U-V space defined by [(3,2),(6,4)]. The points
- of the profile curve are, in fact,
-
- point [ 3.3 2.5, 5.7 2.5, 5.7 3.5, 3.3 3.5 ]
-
- Another tricky area with NURBS profile curves is clearly documented
- but easy to forget: curve orientation. The first profile on a
- trimmed surface must be CCW in U-V parameter space. A CCW profile
- trims the region outside the closed loop formed by the curve (or curves).
- A CW profile trims the region inside the closed loop. The rule of
- thumb is that the trimmed region always lies to the right of the
- trimming curve as you traverse from beginning to end.
-
- If you can't get your trimmed NURBS surfaces to display in inventor,
- install inventor_dev.sw.debug, and use the Inventor Debug libraries.
- setenv LD_LIBRARY_PATH /usr/lib/InventorDebug, then when you run
- ivview from the shell prompt, the debug library will sometimes reveal
- your error.
-
- I have tested the examples on an Indigo 2 Extreme, running Irix 5.2
- and Inventor 2.0. Results may vary on other platforms.
-
- Thanks to Dave Immel and Derrick Burns for the geometry lessons, and
- to Paul David for trampling the path a few steps ahead of me.
-
-
- Aaron Schuman
-
-
-